package com.jnshu.tools.wechat;

import com.jnshu.dto.person.UserDto;
import com.jnshu.exception.MyException;
import com.jnshu.tools.JwtUtil;
import lombok.extern.java.Log;
import org.springframework.stereotype.Component;
import java.io.UnsupportedEncodingException;

/**
 * @author Martin
 * @date 2019/8/6 16:51
 *
 */
@Component
@Log
public class TokenUtil {

    public static String getToken(UserDto userDto){
        //使用JWT创建token
        try {
            log.info("TokenUtil获取UserDto的id为："+userDto.getId());
            return JwtUtil.createToken(userDto.getId());
        }catch (Exception e){
            throw new MyException(10000,"token加密失败");
        }
    }
}
